package com.mall.server.controller;

import com.mall.model.domain.CmsSubject;
import com.mall.model.vo.CommonPage;
import com.mall.model.vo.CommonResult;
import com.mall.server.service.CmsSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService subjectService;

    @GetMapping("/listAll")
    public CommonResult listAll() {

        List<CmsSubject> list = subjectService.listAll();
        return CommonResult.success(list);
    }

    @GetMapping("/list")
    public CommonResult list(@RequestParam(defaultValue = "1") Integer pageNum
            , @RequestParam(defaultValue = "10") Integer pageSize
            , String keyword) {

        CommonPage cp = subjectService.list(pageNum, pageSize, keyword);
        return CommonResult.success(cp);
    }

}
